package cn.edu.hbvtc.qms.web.struts.action;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import cn.edu.hbvtc.qms.domain.Clazz;
import cn.edu.hbvtc.qms.domain.ClazzArrangement;
import cn.edu.hbvtc.qms.domain.Department;
import cn.edu.hbvtc.qms.domain.EvalPeriod;
import cn.edu.hbvtc.qms.domain.Evaluation;
import cn.edu.hbvtc.qms.domain.Major;
import cn.edu.hbvtc.qms.domain.Role;
import cn.edu.hbvtc.qms.domain.Teacher;
import cn.edu.hbvtc.qms.domain.Term;
import cn.edu.hbvtc.qms.domain.User;
import cn.edu.hbvtc.qms.service.IEvaluationService;
import cn.edu.hbvtc.qms.service.IManagementService;
import cn.edu.hbvtc.qms.web.struts.form.CourseEvaluateQueryActionForm;
import cn.edu.hbvtc.qms.web.utils.ExcelDocWriter;

public class CourseEvaluateQueryAction extends AbstractBaseDispatchAction {

	private IEvaluationService evaluationService = null;
	private IManagementService managementService = null;

	public IEvaluationService getEvaluationService() {
		return evaluationService;
	}

	public void setEvaluationService(IEvaluationService evaluationService) {
		this.evaluationService = evaluationService;
	}

	public IManagementService getManagementService() {
		return managementService;
	}

	public void setManagementService(IManagementService managementService) {
		this.managementService = managementService;
	}

	//获得教学评价结果列表
	public ActionForward queryList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		User user = managementService.findUserByUsername(this.getPrincipal().getUsername());

		Role role = managementService.findRoleByName("TEACHER");
		Role role2 = managementService.findRoleByName("ADMIN");
		Role role3 = managementService.findRoleByName("DEPT_ADMIN");
		Role role4 = managementService.findRoleByName("LEADER");
		Role role5 = managementService.findRoleByName("DEPT_LEADER");

		//获得当前学期
		Term term = managementService.findTermOfNow();
		
		//获得本部门当前学期中的最新评价时间
		EvalPeriod ep = null;

		List<Evaluation> evaluationList = new ArrayList<Evaluation>();

		if (user.getRoles().contains(role2) || user.getRoles().contains(role4)) {
			// 获得学校所有教师
			List<Teacher> teacherList = managementService.findTeachers();

			for (Iterator<Teacher> teacherIter = teacherList.iterator(); teacherIter.hasNext();) {
				Teacher teacher = teacherIter.next();

				// 获得与该教师相关的班级课程安排情况
				List<ClazzArrangement> caList = evaluationService.findClazzArrangementOfTeacher(teacher, term);
				if (caList != null && caList.size() > 0) {
					for (Iterator<ClazzArrangement> caIter = caList.iterator(); caIter.hasNext();) {
						ClazzArrangement ca = caIter.next();

						Evaluation evaluation = new Evaluation();
						evaluation.setClazz(ca.getClazz());
						evaluation.setCourse(ca.getCourse());
						evaluation.setEvaluated(ca.getTeacher());
						evaluation.setTerm(term);

						double sumScore = 0;
						double goalScore = 0; //教学目标得分
						double contentScore = 0; //教学内容与资讯得分
						double methodScore = 0; //教学组织与方法得分
						double attitudeScore = 0; //教学态度得分
						double manageScore = 0; //教学管理得分
						double effectScore = 0; //教学效果得分
						
						double score1 = 0;//20项指标评分
						double score2 = 0;
						double score3 = 0;
						double score4 = 0;
						double score5 = 0;
						double score6 = 0;
						double score7 = 0;
						double score8 = 0;
						double score9 = 0;
						double score10 = 0;
						double score11 = 0;
						double score12 = 0;
						double score13 = 0;
						double score14 = 0;
						double score15 = 0;
						double score16 = 0;
						double score17 = 0;
						double score18 = 0;
						double score19 = 0;
						double score20 = 0;
						
						double totalA = 0;//优良中差四个选项总数统计
						double totalB = 0;
						double totalC = 0;
						double totalD = 0;
						
//						StringBuffer suggestion = new StringBuffer();//教学建议改为从数据库中读取

						//获得本部门当前学期中的最新评价时间
						ep = evaluationService.findLateEvalPeriodByDepartmentInThisTerm(teacher.getDept(), term);
						
						List<Evaluation> evList = evaluationService.findEvaluationByClazzArrangementAndEvalPeriod(ca, ep);
						if (evList != null && evList.size() > 0) {
							for (Iterator<Evaluation> evIter = evList.iterator(); evIter.hasNext();) {
								Evaluation ev = evIter.next();
								sumScore += Double.parseDouble(ev.getTotalScore());
								
								//分别获得各项评价项目的分数，教学目标10分、教学内容与资讯25分、教学组织与方法25分、教学态度20分、教学管理10分、教学效果10分
								String[] score = ev.getScore().split(",");
								
								for (int i = 0; i <= score.length -1; i++) {
									if (score[i].equals("5.0")) {
										totalA ++;
									} else if (score[i].equals("4.0")) {
										totalB ++;
									} else if (score[i].equals("3.0")) {
										totalC ++;
									} else if (score[i].equals("2.0")) {
										totalD ++;
									}
								}
								
								score1 += Double.parseDouble(score[0]);
								score2 += Double.parseDouble(score[1]);
								score3 += Double.parseDouble(score[2]);
								score4 += Double.parseDouble(score[3]);
								score5 += Double.parseDouble(score[4]);
								score6 += Double.parseDouble(score[5]);
								score7 += Double.parseDouble(score[6]);
								score8 += Double.parseDouble(score[7]);
								score9 += Double.parseDouble(score[8]);
								score10 += Double.parseDouble(score[9]);
								
								score11 += Double.parseDouble(score[10]);
								score12 += Double.parseDouble(score[11]);
								score13 += Double.parseDouble(score[12]);
								score14 += Double.parseDouble(score[13]);
								score15 += Double.parseDouble(score[14]);
								score16 += Double.parseDouble(score[15]);
								score17 += Double.parseDouble(score[16]);
								score18 += Double.parseDouble(score[17]);
								score19 += Double.parseDouble(score[18]);
								score20 += Double.parseDouble(score[19]);
								
								goalScore += Double.parseDouble(score[0]) + Double.parseDouble(score[1]);
								contentScore += Double.parseDouble(score[2]) + Double.parseDouble(score[3]) + Double.parseDouble(score[4]) + Double.parseDouble(score[5]) + Double.parseDouble(score[6]);
								methodScore += Double.parseDouble(score[7]) + Double.parseDouble(score[8]) + Double.parseDouble(score[9]) + Double.parseDouble(score[10]) + Double.parseDouble(score[11]);
								attitudeScore += Double.parseDouble(score[12]) + Double.parseDouble(score[13]) + Double.parseDouble(score[14]) + Double.parseDouble(score[15]);
								manageScore += Double.parseDouble(score[16]) + Double.parseDouble(score[17]);
								effectScore += Double.parseDouble(score[18]) + Double.parseDouble(score[19]);
//								suggestion.append(ev.getSuggestion() + "}");
							}
							evaluation.setTotalScore(String.valueOf(new DecimalFormat("##.00").format(sumScore / evList.size())));
							evaluation.setGoalScore(String.valueOf(new DecimalFormat("##.00").format(goalScore / (evList.size() * 10) * 100)));
							evaluation.setContentScore(String.valueOf(new DecimalFormat("##.00").format(contentScore / (evList.size() * 25) * 100)));
							evaluation.setMethodScore(String.valueOf(new DecimalFormat("##.00").format(methodScore / (evList.size() * 25) * 100)));
							evaluation.setAttitudeScore(String.valueOf(new DecimalFormat("##.00").format(attitudeScore / (evList.size() * 20) * 100)));
							evaluation.setManageScore(String.valueOf(new DecimalFormat("##.00").format(manageScore / (evList.size() * 10) * 100)));
							evaluation.setEffectScore(String.valueOf(new DecimalFormat("##.00").format(effectScore / (evList.size() * 10) * 100)));
							
							evaluation.setScore1(String.valueOf(new DecimalFormat("##.00").format(score1 / (evList.size() * 5) * 100)));
							evaluation.setScore2(String.valueOf(new DecimalFormat("##.00").format(score2 / (evList.size() * 5) * 100)));
							evaluation.setScore3(String.valueOf(new DecimalFormat("##.00").format(score3 / (evList.size() * 5) * 100)));
							evaluation.setScore4(String.valueOf(new DecimalFormat("##.00").format(score4 / (evList.size() * 5) * 100)));
							evaluation.setScore5(String.valueOf(new DecimalFormat("##.00").format(score5 / (evList.size() * 5) * 100)));
							evaluation.setScore6(String.valueOf(new DecimalFormat("##.00").format(score6 / (evList.size() * 5) * 100)));
							evaluation.setScore7(String.valueOf(new DecimalFormat("##.00").format(score7 / (evList.size() * 5) * 100)));
							evaluation.setScore8(String.valueOf(new DecimalFormat("##.00").format(score8 / (evList.size() * 5) * 100)));
							evaluation.setScore9(String.valueOf(new DecimalFormat("##.00").format(score9 / (evList.size() * 5) * 100)));
							evaluation.setScore10(String.valueOf(new DecimalFormat("##.00").format(score10 / (evList.size() * 5) * 100)));
							
							evaluation.setScore11(String.valueOf(new DecimalFormat("##.00").format(score11 / (evList.size() * 5) * 100)));
							evaluation.setScore12(String.valueOf(new DecimalFormat("##.00").format(score12 / (evList.size() * 5) * 100)));
							evaluation.setScore13(String.valueOf(new DecimalFormat("##.00").format(score13 / (evList.size() * 5) * 100)));
							evaluation.setScore14(String.valueOf(new DecimalFormat("##.00").format(score14 / (evList.size() * 5) * 100)));
							evaluation.setScore15(String.valueOf(new DecimalFormat("##.00").format(score15 / (evList.size() * 5) * 100)));
							evaluation.setScore16(String.valueOf(new DecimalFormat("##.00").format(score16 / (evList.size() * 5) * 100)));
							evaluation.setScore17(String.valueOf(new DecimalFormat("##.00").format(score17 / (evList.size() * 5) * 100)));
							evaluation.setScore18(String.valueOf(new DecimalFormat("##.00").format(score18 / (evList.size() * 5) * 100)));
							evaluation.setScore19(String.valueOf(new DecimalFormat("##.00").format(score19 / (evList.size() * 5) * 100)));
							evaluation.setScore20(String.valueOf(new DecimalFormat("##.00").format(score20 / (evList.size() * 5) * 100)));
							
							evaluation.setTotalA(String.valueOf(new DecimalFormat("##.00").format(totalA / (evList.size() * 20) * 100)));
							evaluation.setTotalB(String.valueOf(new DecimalFormat("##.00").format(totalB / (evList.size() * 20) * 100)));
							evaluation.setTotalC(String.valueOf(new DecimalFormat("##.00").format(totalC / (evList.size() * 20) * 100)));
							evaluation.setTotalD(String.valueOf(new DecimalFormat("##.00").format(totalD / (evList.size() * 20) * 100)));
							
							evaluation.setEvalNumber(String.valueOf(evList.size()));// 设置参评人数
//							evaluation.setSuggestion(suggestion.toString());
							evaluationList.add(evaluation);
						}
					}
				}
			}
		} else if (user.getRoles().contains(role3)|| user.getRoles().contains(role5)) {
			// 获得部门管理员和部门领导所在的部门名称
			Teacher deptTeacher = managementService.findTeacherByUserId(user.getId());

			// 获得该部门下的所有班级
			List<Clazz> clazzAllList = new ArrayList<Clazz>();
			List<Major> majorList = managementService.findMajorsOfDept(deptTeacher.getDept());
			for (Iterator<Major> majorIter = majorList.iterator(); majorIter.hasNext();) {
				List<Clazz> clazzList = managementService.findClazzsOfMajor(majorIter.next());
				clazzAllList.addAll(clazzList);
			}

			for (Iterator<Clazz> clazzIter = clazzAllList.iterator(); clazzIter.hasNext();) {
				Clazz clazz = clazzIter.next();

				// 获得与该班级课程安排情况
				List<ClazzArrangement> caList = evaluationService.findClazzArrangementOfClazz(clazz, term);
				if (caList != null && caList.size() > 0) {
					for (Iterator<ClazzArrangement> caIter = caList.iterator(); caIter.hasNext();) {
						ClazzArrangement ca = caIter.next();

						Evaluation evaluation = new Evaluation();
						evaluation.setClazz(ca.getClazz());
						evaluation.setCourse(ca.getCourse());
						evaluation.setEvaluated(ca.getTeacher());
						evaluation.setTerm(term);

						double sumScore = 0;
						double goalScore = 0; //教学目标得分
						double contentScore = 0; //教学内容与资讯得分
						double methodScore = 0; //教学组织与方法得分
						double attitudeScore = 0; //教学态度得分
						double manageScore = 0; //教学管理得分
						double effectScore = 0; //教学效果得分
						
						double score1 = 0;//20项指标评分
						double score2 = 0;
						double score3 = 0;
						double score4 = 0;
						double score5 = 0;
						double score6 = 0;
						double score7 = 0;
						double score8 = 0;
						double score9 = 0;
						double score10 = 0;
						double score11 = 0;
						double score12 = 0;
						double score13 = 0;
						double score14 = 0;
						double score15 = 0;
						double score16 = 0;
						double score17 = 0;
						double score18 = 0;
						double score19 = 0;
						double score20 = 0;
						
						double totalA = 0;//优良中差四个选项总数统计
						double totalB = 0;
						double totalC = 0;
						double totalD = 0;
						
//						StringBuffer suggestion = new StringBuffer();//教学建议改为从数据库中读取

						//获得本部门当前学期中的最新评价时间
						ep = evaluationService.findLateEvalPeriodByDepartmentInThisTerm(deptTeacher.getDept(), term);
						
						List<Evaluation> evList = evaluationService.findEvaluationByClazzArrangementAndEvalPeriod(ca, ep);
						if (evList != null && evList.size() > 0) {
							for (Iterator<Evaluation> evIter = evList.iterator(); evIter.hasNext();) {
								Evaluation ev = evIter.next();
								sumScore += Double.parseDouble(ev.getTotalScore());
								
								//分别获得各项评价项目的分数，教学目标10分、教学内容与资讯25分、教学组织与方法25分、教学态度20分、教学管理10分、教学效果10分
								String[] score = ev.getScore().split(",");
								
								for (int i = 0; i <= score.length -1; i++) {
									if (score[i].equals("5.0")) {
										totalA ++;
									} else if (score[i].equals("4.0")) {
										totalB ++;
									} else if (score[i].equals("3.0")) {
										totalC ++;
									} else if (score[i].equals("2.0")) {
										totalD ++;
									}
								}
								
								score1 += Double.parseDouble(score[0]);
								score2 += Double.parseDouble(score[1]);
								score3 += Double.parseDouble(score[2]);
								score4 += Double.parseDouble(score[3]);
								score5 += Double.parseDouble(score[4]);
								score6 += Double.parseDouble(score[5]);
								score7 += Double.parseDouble(score[6]);
								score8 += Double.parseDouble(score[7]);
								score9 += Double.parseDouble(score[8]);
								score10 += Double.parseDouble(score[9]);
								
								score11 += Double.parseDouble(score[10]);
								score12 += Double.parseDouble(score[11]);
								score13 += Double.parseDouble(score[12]);
								score14 += Double.parseDouble(score[13]);
								score15 += Double.parseDouble(score[14]);
								score16 += Double.parseDouble(score[15]);
								score17 += Double.parseDouble(score[16]);
								score18 += Double.parseDouble(score[17]);
								score19 += Double.parseDouble(score[18]);
								score20 += Double.parseDouble(score[19]);
								
								goalScore += Double.parseDouble(score[0]) + Double.parseDouble(score[1]);
								contentScore += Double.parseDouble(score[2]) + Double.parseDouble(score[3]) + Double.parseDouble(score[4]) + Double.parseDouble(score[5]) + Double.parseDouble(score[6]);
								methodScore += Double.parseDouble(score[7]) + Double.parseDouble(score[8]) + Double.parseDouble(score[9]) + Double.parseDouble(score[10]) + Double.parseDouble(score[11]);
								attitudeScore += Double.parseDouble(score[12]) + Double.parseDouble(score[13]) + Double.parseDouble(score[14]) + Double.parseDouble(score[15]);
								manageScore += Double.parseDouble(score[16]) + Double.parseDouble(score[17]);
								effectScore += Double.parseDouble(score[18]) + Double.parseDouble(score[19]);
//								suggestion.append(ev.getSuggestion() + "}");
							}
							evaluation.setTotalScore(String.valueOf(new DecimalFormat("##.00").format(sumScore / evList.size())));
							evaluation.setGoalScore(String.valueOf(new DecimalFormat("##.00").format(goalScore / (evList.size() * 10) * 100)));
							evaluation.setContentScore(String.valueOf(new DecimalFormat("##.00").format(contentScore / (evList.size() * 25) * 100)));
							evaluation.setMethodScore(String.valueOf(new DecimalFormat("##.00").format(methodScore / (evList.size() * 25) * 100)));
							evaluation.setAttitudeScore(String.valueOf(new DecimalFormat("##.00").format(attitudeScore / (evList.size() * 20) * 100)));
							evaluation.setManageScore(String.valueOf(new DecimalFormat("##.00").format(manageScore / (evList.size() * 10) * 100)));
							evaluation.setEffectScore(String.valueOf(new DecimalFormat("##.00").format(effectScore / (evList.size() * 10) * 100)));
							
							evaluation.setScore1(String.valueOf(new DecimalFormat("##.00").format(score1 / (evList.size() * 5) * 100)));
							evaluation.setScore2(String.valueOf(new DecimalFormat("##.00").format(score2 / (evList.size() * 5) * 100)));
							evaluation.setScore3(String.valueOf(new DecimalFormat("##.00").format(score3 / (evList.size() * 5) * 100)));
							evaluation.setScore4(String.valueOf(new DecimalFormat("##.00").format(score4 / (evList.size() * 5) * 100)));
							evaluation.setScore5(String.valueOf(new DecimalFormat("##.00").format(score5 / (evList.size() * 5) * 100)));
							evaluation.setScore6(String.valueOf(new DecimalFormat("##.00").format(score6 / (evList.size() * 5) * 100)));
							evaluation.setScore7(String.valueOf(new DecimalFormat("##.00").format(score7 / (evList.size() * 5) * 100)));
							evaluation.setScore8(String.valueOf(new DecimalFormat("##.00").format(score8 / (evList.size() * 5) * 100)));
							evaluation.setScore9(String.valueOf(new DecimalFormat("##.00").format(score9 / (evList.size() * 5) * 100)));
							evaluation.setScore10(String.valueOf(new DecimalFormat("##.00").format(score10 / (evList.size() * 5) * 100)));
							
							evaluation.setScore11(String.valueOf(new DecimalFormat("##.00").format(score11 / (evList.size() * 5) * 100)));
							evaluation.setScore12(String.valueOf(new DecimalFormat("##.00").format(score12 / (evList.size() * 5) * 100)));
							evaluation.setScore13(String.valueOf(new DecimalFormat("##.00").format(score13 / (evList.size() * 5) * 100)));
							evaluation.setScore14(String.valueOf(new DecimalFormat("##.00").format(score14 / (evList.size() * 5) * 100)));
							evaluation.setScore15(String.valueOf(new DecimalFormat("##.00").format(score15 / (evList.size() * 5) * 100)));
							evaluation.setScore16(String.valueOf(new DecimalFormat("##.00").format(score16 / (evList.size() * 5) * 100)));
							evaluation.setScore17(String.valueOf(new DecimalFormat("##.00").format(score17 / (evList.size() * 5) * 100)));
							evaluation.setScore18(String.valueOf(new DecimalFormat("##.00").format(score18 / (evList.size() * 5) * 100)));
							evaluation.setScore19(String.valueOf(new DecimalFormat("##.00").format(score19 / (evList.size() * 5) * 100)));
							evaluation.setScore20(String.valueOf(new DecimalFormat("##.00").format(score20 / (evList.size() * 5) * 100)));
							
							evaluation.setTotalA(String.valueOf(new DecimalFormat("##.00").format(totalA / (evList.size() * 20) * 100)));
							evaluation.setTotalB(String.valueOf(new DecimalFormat("##.00").format(totalB / (evList.size() * 20) * 100)));
							evaluation.setTotalC(String.valueOf(new DecimalFormat("##.00").format(totalC / (evList.size() * 20) * 100)));
							evaluation.setTotalD(String.valueOf(new DecimalFormat("##.00").format(totalD / (evList.size() * 20) * 100)));
							
							evaluation.setEvalNumber(String.valueOf(evList.size()));// 设置参评人数
//							evaluation.setSuggestion(suggestion.toString());
							evaluationList.add(evaluation);
						}
					}
				}
			}
		} else if (user.getRoles().contains(role)) {
			Teacher teacher = managementService.findTeacherById(user.getId());

			// 获得与该教师相关的班级课程安排情况
			List<ClazzArrangement> caList = evaluationService.findClazzArrangementOfTeacher(teacher, term);
			if (caList != null && caList.size() > 0) {
				for (Iterator<ClazzArrangement> caIter = caList.iterator(); caIter.hasNext();) {
					ClazzArrangement ca = caIter.next();

					Evaluation evaluation = new Evaluation();
					evaluation.setClazz(ca.getClazz());
					evaluation.setCourse(ca.getCourse());
					evaluation.setEvaluated(ca.getTeacher());
					evaluation.setTerm(term);

					double sumScore = 0;
					double goalScore = 0; //教学目标得分
					double contentScore = 0; //教学内容与资讯得分
					double methodScore = 0; //教学组织与方法得分
					double attitudeScore = 0; //教学态度得分
					double manageScore = 0; //教学管理得分
					double effectScore = 0; //教学效果得分
					
					double score1 = 0;//20项指标评分
					double score2 = 0;
					double score3 = 0;
					double score4 = 0;
					double score5 = 0;
					double score6 = 0;
					double score7 = 0;
					double score8 = 0;
					double score9 = 0;
					double score10 = 0;
					double score11 = 0;
					double score12 = 0;
					double score13 = 0;
					double score14 = 0;
					double score15 = 0;
					double score16 = 0;
					double score17 = 0;
					double score18 = 0;
					double score19 = 0;
					double score20 = 0;
					
					double totalA = 0;//优良中差四个选项总数统计
					double totalB = 0;
					double totalC = 0;
					double totalD = 0;
					
//					StringBuffer suggestion = new StringBuffer();//教学建议改为从数据库中读取

					//获得本部门当前学期中的最新评价时间
					ep = evaluationService.findLateEvalPeriodByDepartmentInThisTerm(teacher.getDept(), term);
					
					List<Evaluation> evList = evaluationService.findEvaluationByClazzArrangementAndEvalPeriod(ca, ep);
					if (evList != null && evList.size() > 0) {
						for (Iterator<Evaluation> evIter = evList.iterator(); evIter.hasNext();) {
							Evaluation ev = evIter.next();
							sumScore += Double.parseDouble(ev.getTotalScore());
							
							//分别获得各项评价项目的分数，教学目标10分、教学内容与资讯25分、教学组织与方法25分、教学态度20分、教学管理10分、教学效果10分
							String[] score = ev.getScore().split(",");
							
							for (int i = 0; i <= score.length -1; i++) {
								if (score[i].equals("5.0")) {
									totalA ++;
								} else if (score[i].equals("4.0")) {
									totalB ++;
								} else if (score[i].equals("3.0")) {
									totalC ++;
								} else if (score[i].equals("2.0")) {
									totalD ++;
								}
							}
							
							score1 += Double.parseDouble(score[0]);
							score2 += Double.parseDouble(score[1]);
							score3 += Double.parseDouble(score[2]);
							score4 += Double.parseDouble(score[3]);
							score5 += Double.parseDouble(score[4]);
							score6 += Double.parseDouble(score[5]);
							score7 += Double.parseDouble(score[6]);
							score8 += Double.parseDouble(score[7]);
							score9 += Double.parseDouble(score[8]);
							score10 += Double.parseDouble(score[9]);
							
							score11 += Double.parseDouble(score[10]);
							score12 += Double.parseDouble(score[11]);
							score13 += Double.parseDouble(score[12]);
							score14 += Double.parseDouble(score[13]);
							score15 += Double.parseDouble(score[14]);
							score16 += Double.parseDouble(score[15]);
							score17 += Double.parseDouble(score[16]);
							score18 += Double.parseDouble(score[17]);
							score19 += Double.parseDouble(score[18]);
							score20 += Double.parseDouble(score[19]);
							
							goalScore += Double.parseDouble(score[0]) + Double.parseDouble(score[1]);
							contentScore += Double.parseDouble(score[2]) + Double.parseDouble(score[3]) + Double.parseDouble(score[4]) + Double.parseDouble(score[5]) + Double.parseDouble(score[6]);
							methodScore += Double.parseDouble(score[7]) + Double.parseDouble(score[8]) + Double.parseDouble(score[9]) + Double.parseDouble(score[10]) + Double.parseDouble(score[11]);
							attitudeScore += Double.parseDouble(score[12]) + Double.parseDouble(score[13]) + Double.parseDouble(score[14]) + Double.parseDouble(score[15]);
							manageScore += Double.parseDouble(score[16]) + Double.parseDouble(score[17]);
							effectScore += Double.parseDouble(score[18]) + Double.parseDouble(score[19]);
//							suggestion.append(ev.getSuggestion() + "}");
						}
						evaluation.setTotalScore(String.valueOf(new DecimalFormat("##.00").format(sumScore / evList.size())));
						evaluation.setGoalScore(String.valueOf(new DecimalFormat("##.00").format(goalScore / (evList.size() * 10) * 100)));
						evaluation.setContentScore(String.valueOf(new DecimalFormat("##.00").format(contentScore / (evList.size() * 25) * 100)));
						evaluation.setMethodScore(String.valueOf(new DecimalFormat("##.00").format(methodScore / (evList.size() * 25) * 100)));
						evaluation.setAttitudeScore(String.valueOf(new DecimalFormat("##.00").format(attitudeScore / (evList.size() * 20) * 100)));
						evaluation.setManageScore(String.valueOf(new DecimalFormat("##.00").format(manageScore / (evList.size() * 10) * 100)));
						evaluation.setEffectScore(String.valueOf(new DecimalFormat("##.00").format(effectScore / (evList.size() * 10) * 100)));
						
						evaluation.setScore1(String.valueOf(new DecimalFormat("##.00").format(score1 / (evList.size() * 5) * 100)));
						evaluation.setScore2(String.valueOf(new DecimalFormat("##.00").format(score2 / (evList.size() * 5) * 100)));
						evaluation.setScore3(String.valueOf(new DecimalFormat("##.00").format(score3 / (evList.size() * 5) * 100)));
						evaluation.setScore4(String.valueOf(new DecimalFormat("##.00").format(score4 / (evList.size() * 5) * 100)));
						evaluation.setScore5(String.valueOf(new DecimalFormat("##.00").format(score5 / (evList.size() * 5) * 100)));
						evaluation.setScore6(String.valueOf(new DecimalFormat("##.00").format(score6 / (evList.size() * 5) * 100)));
						evaluation.setScore7(String.valueOf(new DecimalFormat("##.00").format(score7 / (evList.size() * 5) * 100)));
						evaluation.setScore8(String.valueOf(new DecimalFormat("##.00").format(score8 / (evList.size() * 5) * 100)));
						evaluation.setScore9(String.valueOf(new DecimalFormat("##.00").format(score9 / (evList.size() * 5) * 100)));
						evaluation.setScore10(String.valueOf(new DecimalFormat("##.00").format(score10 / (evList.size() * 5) * 100)));
						
						evaluation.setScore11(String.valueOf(new DecimalFormat("##.00").format(score11 / (evList.size() * 5) * 100)));
						evaluation.setScore12(String.valueOf(new DecimalFormat("##.00").format(score12 / (evList.size() * 5) * 100)));
						evaluation.setScore13(String.valueOf(new DecimalFormat("##.00").format(score13 / (evList.size() * 5) * 100)));
						evaluation.setScore14(String.valueOf(new DecimalFormat("##.00").format(score14 / (evList.size() * 5) * 100)));
						evaluation.setScore15(String.valueOf(new DecimalFormat("##.00").format(score15 / (evList.size() * 5) * 100)));
						evaluation.setScore16(String.valueOf(new DecimalFormat("##.00").format(score16 / (evList.size() * 5) * 100)));
						evaluation.setScore17(String.valueOf(new DecimalFormat("##.00").format(score17 / (evList.size() * 5) * 100)));
						evaluation.setScore18(String.valueOf(new DecimalFormat("##.00").format(score18 / (evList.size() * 5) * 100)));
						evaluation.setScore19(String.valueOf(new DecimalFormat("##.00").format(score19 / (evList.size() * 5) * 100)));
						evaluation.setScore20(String.valueOf(new DecimalFormat("##.00").format(score20 / (evList.size() * 5) * 100)));
						
						evaluation.setTotalA(String.valueOf(new DecimalFormat("##.00").format(totalA / (evList.size() * 20) * 100)));
						evaluation.setTotalB(String.valueOf(new DecimalFormat("##.00").format(totalB / (evList.size() * 20) * 100)));
						evaluation.setTotalC(String.valueOf(new DecimalFormat("##.00").format(totalC / (evList.size() * 20) * 100)));
						evaluation.setTotalD(String.valueOf(new DecimalFormat("##.00").format(totalD / (evList.size() * 20) * 100)));
						
						evaluation.setEvalNumber(String.valueOf(evList.size()));// 设置参评人数
//						evaluation.setSuggestion(suggestion.toString());
						evaluationList.add(evaluation);
					}
				}
			}
		}

		request.setAttribute("evaluationList", evaluationList);
		request.setAttribute("ep", ep);
		
		HttpSession session = request.getSession();
		session.setAttribute("evaluationList", evaluationList);// 将课程评价查询结果保存到session对象中，便于生成EXCEL文档和打印

		return mapping.findForward("courseEvaluateQueryList");
	}

	// 获得某教师的教学建议
	public ActionForward showSuggestionDetails(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		// 获得某教师本学期的教学安排对象，从而搜索出所有的教学建议
		ClazzArrangement ca = new ClazzArrangement();
		ca.setClazz(managementService.findClazzById(Integer.parseInt(request.getParameter("clazzId"))));
		ca.setCourse(managementService.findCourseById(Integer.parseInt(request.getParameter("courseId"))));
		ca.setTeacher(managementService.findTeacherById(Integer.parseInt(request.getParameter("teacherId"))));
		ca.setTerm(managementService.findTermById(Integer.parseInt(request.getParameter("termId"))));

		//获得评价时间段
		EvalPeriod ep = evaluationService.findEvalPeriodById(Integer.parseInt(request.getParameter("epId")));
		
		List<String> suggestionList = new ArrayList<String>();
		List<Evaluation> evList = evaluationService.findEvaluationByClazzArrangementAndEvalPeriod(ca, ep);
		if (evList != null && evList.size() > 0) {
			for (Iterator<Evaluation> evIter = evList.iterator(); evIter.hasNext();) {
				Evaluation ev = evIter.next();
				suggestionList.add(ev.getSuggestion());
			}
		}

		request.setAttribute("suggestionList", suggestionList);

		return mapping.findForward("showSuggestionDetails");
	}

	//跳转到历史评价记录查询页面
	public ActionForward queryForHistory(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		User user = managementService.findUserByUsername(this.getPrincipal().getUsername());

		List<Term> termList = managementService.findTerms();
		request.setAttribute("termList", termList);

		List<Department> deptList = new ArrayList<Department>();
		
		Role role1 = managementService.findRoleByName("TEACHER");
		Role role2 = managementService.findRoleByName("ADMIN");
		Role role3 = managementService.findRoleByName("DEPT_ADMIN");
		Role role4 = managementService.findRoleByName("LEADER");
		Role role5 = managementService.findRoleByName("DEPT_LEADER");

		if (user.getRoles().contains(role3) || user.getRoles().contains(role5)) {
			// 部门管理员和领导可以查询本部门所有教师的课程评价历史数据
			Teacher teacher = managementService.findTeacherById(user.getId());
			Department dept = teacher.getDept();
			deptList.add(dept);
		} else if (user.getRoles().contains(role2)
				|| user.getRoles().contains(role4)) {
			// 超级管理员和学校领导可以查询本校所有部门的相关教师的课程评价历史数据
			deptList = managementService.findDepartments();
		} else if (user.getRoles().contains(role1)) {
			// 教师用户只能查询自己的课程评价历史数据
			Teacher teacher = managementService.findTeacherById(user.getId());
			Department dept = teacher.getDept();
			deptList.add(dept);
		}

		request.setAttribute("deptList", deptList);

		return mapping.findForward("queryForHistory");
	}

	//获得历史评价记录查询结果
	public ActionForward queryForHistoryList(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CourseEvaluateQueryActionForm cqaf = (CourseEvaluateQueryActionForm) form;

		Term term = managementService.findTermById(cqaf.getTermId());
		EvalPeriod ep = evaluationService.findEvalPeriodById(cqaf.getEvalPeriodId());

		List<Evaluation> evaluationList = new ArrayList<Evaluation>();

		if (cqaf.getTeacherId() != 0) {
			Teacher teacher = managementService.findTeacherById(cqaf.getTeacherId());

			// 获得与该教师相关的班级课程安排情况
			List<ClazzArrangement> caList = evaluationService.findClazzArrangementOfTeacher(teacher, term);
			if (caList != null && caList.size() > 0) {
				for (Iterator<ClazzArrangement> caIter = caList.iterator(); caIter.hasNext();) {
					ClazzArrangement ca = caIter.next();

					Evaluation evaluation = new Evaluation();
					evaluation.setClazz(ca.getClazz());
					evaluation.setCourse(ca.getCourse());
					evaluation.setEvaluated(ca.getTeacher());
					evaluation.setTerm(ca.getTerm());

					double sumScore = 0;
					double goalScore = 0; //教学目标得分
					double contentScore = 0; //教学内容与资讯得分
					double methodScore = 0; //教学组织与方法得分
					double attitudeScore = 0; //教学态度得分
					double manageScore = 0; //教学管理得分
					double effectScore = 0; //教学效果得分
					
					double score1 = 0;//20项指标评分
					double score2 = 0;
					double score3 = 0;
					double score4 = 0;
					double score5 = 0;
					double score6 = 0;
					double score7 = 0;
					double score8 = 0;
					double score9 = 0;
					double score10 = 0;
					double score11 = 0;
					double score12 = 0;
					double score13 = 0;
					double score14 = 0;
					double score15 = 0;
					double score16 = 0;
					double score17 = 0;
					double score18 = 0;
					double score19 = 0;
					double score20 = 0;
					
					double totalA = 0;//优良中差四个选项总数统计
					double totalB = 0;
					double totalC = 0;
					double totalD = 0;
					
//					StringBuffer suggestion = new StringBuffer();//教学建议改为从数据库中读取

					List<Evaluation> evList = evaluationService.findEvaluationByClazzArrangementAndEvalPeriod(ca, ep);
					if (evList != null && evList.size() > 0) {
						for (Iterator<Evaluation> evIter = evList.iterator(); evIter.hasNext();) {
							Evaluation ev = evIter.next();
							sumScore += Double.parseDouble(ev.getTotalScore());
							
							//分别获得各项评价项目的分数，教学目标10分、教学内容与资讯25分、教学组织与方法25分、教学态度20分、教学管理10分、教学效果10分
							String[] score = ev.getScore().split(",");
							
							for (int i = 0; i <= score.length -1; i++) {
								if (score[i].equals("5.0")) {
									totalA ++;
								} else if (score[i].equals("4.0")) {
									totalB ++;
								} else if (score[i].equals("3.0")) {
									totalC ++;
								} else if (score[i].equals("2.0")) {
									totalD ++;
								}
							}
							
							score1 += Double.parseDouble(score[0]);
							score2 += Double.parseDouble(score[1]);
							score3 += Double.parseDouble(score[2]);
							score4 += Double.parseDouble(score[3]);
							score5 += Double.parseDouble(score[4]);
							score6 += Double.parseDouble(score[5]);
							score7 += Double.parseDouble(score[6]);
							score8 += Double.parseDouble(score[7]);
							score9 += Double.parseDouble(score[8]);
							score10 += Double.parseDouble(score[9]);
							
							score11 += Double.parseDouble(score[10]);
							score12 += Double.parseDouble(score[11]);
							score13 += Double.parseDouble(score[12]);
							score14 += Double.parseDouble(score[13]);
							score15 += Double.parseDouble(score[14]);
							score16 += Double.parseDouble(score[15]);
							score17 += Double.parseDouble(score[16]);
							score18 += Double.parseDouble(score[17]);
							score19 += Double.parseDouble(score[18]);
							score20 += Double.parseDouble(score[19]);
							
							goalScore += Double.parseDouble(score[0]) + Double.parseDouble(score[1]);
							contentScore += Double.parseDouble(score[2]) + Double.parseDouble(score[3]) + Double.parseDouble(score[4]) + Double.parseDouble(score[5]) + Double.parseDouble(score[6]);
							methodScore += Double.parseDouble(score[7]) + Double.parseDouble(score[8]) + Double.parseDouble(score[9]) + Double.parseDouble(score[10]) + Double.parseDouble(score[11]);
							attitudeScore += Double.parseDouble(score[12]) + Double.parseDouble(score[13]) + Double.parseDouble(score[14]) + Double.parseDouble(score[15]);
							manageScore += Double.parseDouble(score[16]) + Double.parseDouble(score[17]);
							effectScore += Double.parseDouble(score[18]) + Double.parseDouble(score[19]);
//							suggestion.append(ev.getSuggestion() + "}");
						}
						evaluation.setTotalScore(String.valueOf(new DecimalFormat("##.00").format(sumScore / evList.size())));
						evaluation.setGoalScore(String.valueOf(new DecimalFormat("##.00").format(goalScore / (evList.size() * 10) * 100)));
						evaluation.setContentScore(String.valueOf(new DecimalFormat("##.00").format(contentScore / (evList.size() * 25) * 100)));
						evaluation.setMethodScore(String.valueOf(new DecimalFormat("##.00").format(methodScore / (evList.size() * 25) * 100)));
						evaluation.setAttitudeScore(String.valueOf(new DecimalFormat("##.00").format(attitudeScore / (evList.size() * 20) * 100)));
						evaluation.setManageScore(String.valueOf(new DecimalFormat("##.00").format(manageScore / (evList.size() * 10) * 100)));
						evaluation.setEffectScore(String.valueOf(new DecimalFormat("##.00").format(effectScore / (evList.size() * 10) * 100)));
						
						evaluation.setScore1(String.valueOf(new DecimalFormat("##.00").format(score1 / (evList.size() * 5) * 100)));
						evaluation.setScore2(String.valueOf(new DecimalFormat("##.00").format(score2 / (evList.size() * 5) * 100)));
						evaluation.setScore3(String.valueOf(new DecimalFormat("##.00").format(score3 / (evList.size() * 5) * 100)));
						evaluation.setScore4(String.valueOf(new DecimalFormat("##.00").format(score4 / (evList.size() * 5) * 100)));
						evaluation.setScore5(String.valueOf(new DecimalFormat("##.00").format(score5 / (evList.size() * 5) * 100)));
						evaluation.setScore6(String.valueOf(new DecimalFormat("##.00").format(score6 / (evList.size() * 5) * 100)));
						evaluation.setScore7(String.valueOf(new DecimalFormat("##.00").format(score7 / (evList.size() * 5) * 100)));
						evaluation.setScore8(String.valueOf(new DecimalFormat("##.00").format(score8 / (evList.size() * 5) * 100)));
						evaluation.setScore9(String.valueOf(new DecimalFormat("##.00").format(score9 / (evList.size() * 5) * 100)));
						evaluation.setScore10(String.valueOf(new DecimalFormat("##.00").format(score10 / (evList.size() * 5) * 100)));
						
						evaluation.setScore11(String.valueOf(new DecimalFormat("##.00").format(score11 / (evList.size() * 5) * 100)));
						evaluation.setScore12(String.valueOf(new DecimalFormat("##.00").format(score12 / (evList.size() * 5) * 100)));
						evaluation.setScore13(String.valueOf(new DecimalFormat("##.00").format(score13 / (evList.size() * 5) * 100)));
						evaluation.setScore14(String.valueOf(new DecimalFormat("##.00").format(score14 / (evList.size() * 5) * 100)));
						evaluation.setScore15(String.valueOf(new DecimalFormat("##.00").format(score15 / (evList.size() * 5) * 100)));
						evaluation.setScore16(String.valueOf(new DecimalFormat("##.00").format(score16 / (evList.size() * 5) * 100)));
						evaluation.setScore17(String.valueOf(new DecimalFormat("##.00").format(score17 / (evList.size() * 5) * 100)));
						evaluation.setScore18(String.valueOf(new DecimalFormat("##.00").format(score18 / (evList.size() * 5) * 100)));
						evaluation.setScore19(String.valueOf(new DecimalFormat("##.00").format(score19 / (evList.size() * 5) * 100)));
						evaluation.setScore20(String.valueOf(new DecimalFormat("##.00").format(score20 / (evList.size() * 5) * 100)));
						
						evaluation.setTotalA(String.valueOf(new DecimalFormat("##.00").format(totalA / (evList.size() * 20) * 100)));
						evaluation.setTotalB(String.valueOf(new DecimalFormat("##.00").format(totalB / (evList.size() * 20) * 100)));
						evaluation.setTotalC(String.valueOf(new DecimalFormat("##.00").format(totalC / (evList.size() * 20) * 100)));
						evaluation.setTotalD(String.valueOf(new DecimalFormat("##.00").format(totalD / (evList.size() * 20) * 100)));
						
						evaluation.setEvalNumber(String.valueOf(evList.size()));// 设置参评人数
//						evaluation.setSuggestion(suggestion.toString());
						evaluationList.add(evaluation);
					}
				}
			}
		} else {
			Department dept = managementService.findDepartmentById(cqaf.getDeptId());

			// 获得该部门下的所有班级
			List<Clazz> clazzAllList = new ArrayList<Clazz>();
			List<Major> majorList = managementService.findMajorsOfDept(dept);
			for (Iterator<Major> majorIter = majorList.iterator(); majorIter.hasNext();) {
				List<Clazz> clazzList = managementService.findClazzsOfMajor(majorIter.next());
				clazzAllList.addAll(clazzList);
			}

			for (Iterator<Clazz> clazzIter = clazzAllList.iterator(); clazzIter.hasNext();) {
				Clazz clazz = clazzIter.next();

				// 获得与该班级课程安排情况
				List<ClazzArrangement> caList = evaluationService.findClazzArrangementOfClazz(clazz, term);
				if (caList != null && caList.size() > 0) {
					for (Iterator<ClazzArrangement> caIter = caList.iterator(); caIter.hasNext();) {
						ClazzArrangement ca = caIter.next();

						Evaluation evaluation = new Evaluation();
						evaluation.setClazz(ca.getClazz());
						evaluation.setCourse(ca.getCourse());
						evaluation.setEvaluated(ca.getTeacher());
						evaluation.setTerm(ca.getTerm());

						double sumScore = 0;
						double goalScore = 0; //教学目标得分
						double contentScore = 0; //教学内容与资讯得分
						double methodScore = 0; //教学组织与方法得分
						double attitudeScore = 0; //教学态度得分
						double manageScore = 0; //教学管理得分
						double effectScore = 0; //教学效果得分
						
						double score1 = 0;//20项指标评分
						double score2 = 0;
						double score3 = 0;
						double score4 = 0;
						double score5 = 0;
						double score6 = 0;
						double score7 = 0;
						double score8 = 0;
						double score9 = 0;
						double score10 = 0;
						double score11 = 0;
						double score12 = 0;
						double score13 = 0;
						double score14 = 0;
						double score15 = 0;
						double score16 = 0;
						double score17 = 0;
						double score18 = 0;
						double score19 = 0;
						double score20 = 0;
						
						double totalA = 0;//优良中差四个选项总数统计
						double totalB = 0;
						double totalC = 0;
						double totalD = 0;
						
//						StringBuffer suggestion = new StringBuffer();//教学建议改为从数据库中读取

						List<Evaluation> evList = evaluationService.findEvaluationByClazzArrangementAndEvalPeriod(ca, ep);
						if (evList != null && evList.size() > 0) {
							for (Iterator<Evaluation> evIter = evList.iterator(); evIter.hasNext();) {
								Evaluation ev = evIter.next();
								sumScore += Double.parseDouble(ev.getTotalScore());
								
								//分别获得各项评价项目的分数，教学目标10分、教学内容与资讯25分、教学组织与方法25分、教学态度20分、教学管理10分、教学效果10分
								String[] score = ev.getScore().split(",");
								
								for (int i = 0; i <= score.length -1; i++) {
									if (score[i].equals("5.0")) {
										totalA ++;
									} else if (score[i].equals("4.0")) {
										totalB ++;
									} else if (score[i].equals("3.0")) {
										totalC ++;
									} else if (score[i].equals("2.0")) {
										totalD ++;
									}
								}
								
								score1 += Double.parseDouble(score[0]);
								score2 += Double.parseDouble(score[1]);
								score3 += Double.parseDouble(score[2]);
								score4 += Double.parseDouble(score[3]);
								score5 += Double.parseDouble(score[4]);
								score6 += Double.parseDouble(score[5]);
								score7 += Double.parseDouble(score[6]);
								score8 += Double.parseDouble(score[7]);
								score9 += Double.parseDouble(score[8]);
								score10 += Double.parseDouble(score[9]);
								
								score11 += Double.parseDouble(score[10]);
								score12 += Double.parseDouble(score[11]);
								score13 += Double.parseDouble(score[12]);
								score14 += Double.parseDouble(score[13]);
								score15 += Double.parseDouble(score[14]);
								score16 += Double.parseDouble(score[15]);
								score17 += Double.parseDouble(score[16]);
								score18 += Double.parseDouble(score[17]);
								score19 += Double.parseDouble(score[18]);
								score20 += Double.parseDouble(score[19]);
								
								goalScore += Double.parseDouble(score[0]) + Double.parseDouble(score[1]);
								contentScore += Double.parseDouble(score[2]) + Double.parseDouble(score[3]) + Double.parseDouble(score[4]) + Double.parseDouble(score[5]) + Double.parseDouble(score[6]);
								methodScore += Double.parseDouble(score[7]) + Double.parseDouble(score[8]) + Double.parseDouble(score[9]) + Double.parseDouble(score[10]) + Double.parseDouble(score[11]);
								attitudeScore += Double.parseDouble(score[12]) + Double.parseDouble(score[13]) + Double.parseDouble(score[14]) + Double.parseDouble(score[15]);
								manageScore += Double.parseDouble(score[16]) + Double.parseDouble(score[17]);
								effectScore += Double.parseDouble(score[18]) + Double.parseDouble(score[19]);
//								suggestion.append(ev.getSuggestion() + "}");
							}
							evaluation.setTotalScore(String.valueOf(new DecimalFormat("##.00").format(sumScore / evList.size())));
							evaluation.setGoalScore(String.valueOf(new DecimalFormat("##.00").format(goalScore / (evList.size() * 10) * 100)));
							evaluation.setContentScore(String.valueOf(new DecimalFormat("##.00").format(contentScore / (evList.size() * 25) * 100)));
							evaluation.setMethodScore(String.valueOf(new DecimalFormat("##.00").format(methodScore / (evList.size() * 25) * 100)));
							evaluation.setAttitudeScore(String.valueOf(new DecimalFormat("##.00").format(attitudeScore / (evList.size() * 20) * 100)));
							evaluation.setManageScore(String.valueOf(new DecimalFormat("##.00").format(manageScore / (evList.size() * 10) * 100)));
							evaluation.setEffectScore(String.valueOf(new DecimalFormat("##.00").format(effectScore / (evList.size() * 10) * 100)));
							
							evaluation.setScore1(String.valueOf(new DecimalFormat("##.00").format(score1 / (evList.size() * 5) * 100)));
							evaluation.setScore2(String.valueOf(new DecimalFormat("##.00").format(score2 / (evList.size() * 5) * 100)));
							evaluation.setScore3(String.valueOf(new DecimalFormat("##.00").format(score3 / (evList.size() * 5) * 100)));
							evaluation.setScore4(String.valueOf(new DecimalFormat("##.00").format(score4 / (evList.size() * 5) * 100)));
							evaluation.setScore5(String.valueOf(new DecimalFormat("##.00").format(score5 / (evList.size() * 5) * 100)));
							evaluation.setScore6(String.valueOf(new DecimalFormat("##.00").format(score6 / (evList.size() * 5) * 100)));
							evaluation.setScore7(String.valueOf(new DecimalFormat("##.00").format(score7 / (evList.size() * 5) * 100)));
							evaluation.setScore8(String.valueOf(new DecimalFormat("##.00").format(score8 / (evList.size() * 5) * 100)));
							evaluation.setScore9(String.valueOf(new DecimalFormat("##.00").format(score9 / (evList.size() * 5) * 100)));
							evaluation.setScore10(String.valueOf(new DecimalFormat("##.00").format(score10 / (evList.size() * 5) * 100)));
							
							evaluation.setScore11(String.valueOf(new DecimalFormat("##.00").format(score11 / (evList.size() * 5) * 100)));
							evaluation.setScore12(String.valueOf(new DecimalFormat("##.00").format(score12 / (evList.size() * 5) * 100)));
							evaluation.setScore13(String.valueOf(new DecimalFormat("##.00").format(score13 / (evList.size() * 5) * 100)));
							evaluation.setScore14(String.valueOf(new DecimalFormat("##.00").format(score14 / (evList.size() * 5) * 100)));
							evaluation.setScore15(String.valueOf(new DecimalFormat("##.00").format(score15 / (evList.size() * 5) * 100)));
							evaluation.setScore16(String.valueOf(new DecimalFormat("##.00").format(score16 / (evList.size() * 5) * 100)));
							evaluation.setScore17(String.valueOf(new DecimalFormat("##.00").format(score17 / (evList.size() * 5) * 100)));
							evaluation.setScore18(String.valueOf(new DecimalFormat("##.00").format(score18 / (evList.size() * 5) * 100)));
							evaluation.setScore19(String.valueOf(new DecimalFormat("##.00").format(score19 / (evList.size() * 5) * 100)));
							evaluation.setScore20(String.valueOf(new DecimalFormat("##.00").format(score20 / (evList.size() * 5) * 100)));
							
							evaluation.setTotalA(String.valueOf(new DecimalFormat("##.00").format(totalA / (evList.size() * 20) * 100)));
							evaluation.setTotalB(String.valueOf(new DecimalFormat("##.00").format(totalB / (evList.size() * 20) * 100)));
							evaluation.setTotalC(String.valueOf(new DecimalFormat("##.00").format(totalC / (evList.size() * 20) * 100)));
							evaluation.setTotalD(String.valueOf(new DecimalFormat("##.00").format(totalD / (evList.size() * 20) * 100)));
							
							evaluation.setEvalNumber(String.valueOf(evList.size()));// 设置参评人数
//							evaluation.setSuggestion(suggestion.toString());
							evaluationList.add(evaluation);
						}
					}
				}
			}
		}

		request.setAttribute("evaluationList", evaluationList);
		request.setAttribute("ep", ep);
		
		HttpSession session = request.getSession();
		session.setAttribute("evaluationList", evaluationList);// 将课程评价查询结果保存到session对象中，便于生成EXCEL文档和打印

		return mapping.findForward("queryForHistoryList");
	}

	// 生成EXCEL文档
	@SuppressWarnings("unchecked")
	public ActionForward buildExcelDoc(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HttpSession session = request.getSession();
		List<Evaluation> evaluations = (List<Evaluation>) session.getAttribute("evaluationList");

		response.setContentType("application/x-msexcel;charset=UTF-8");
		ExcelDocWriter.buildExcelDoc(evaluations, response.getOutputStream());

		session.removeAttribute("evaluationList");// 从session对象中去掉evaluationList对象，释放内存
		return null;
	}
}
